int dis[N];
bool state[N];
int dij()
{
    memset(dis,0x3f3f3f3f,sizeof dis);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>> >heap;
    heap.push({0,1});
    dis[1] = 0;
    while(!heap.empty())
    {
        auto x = heap.top();
        heap.pop();
        int disx= x.first;
        int node = x.second;
        if(state[node]==0)
        {
            state[node] = 1;
        }
        else
        {
            continue;
        }
        for(int i = h[node];i!=-1;i = ne[i])
        {
            int j = e[i];
            if(dis[j]>disx + w[i])
            {
                dis[j] = disx + w[i];
                heap.push({dis[j],j});
            }
        }
    }
    if(dis[n]==0x3f3f3f3f)
    {
        return -1;
    }
    else return dis[n];
}